home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: IdleTasks.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1990-1993 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes. */
-
- /* This function is called when a null event is received. Do appropriate tasks
- ** for null event situations, such as handling balloon help for window. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.protos.h" /* Get the prototypes for application. */
-
- extern OSType gAppWindowType;
- extern short gDialogErr;
-
- Boolean gStartingUp = true;
-
-
-
- /*****************************************************************************/
- /*****************************************************************************/
-
-
-
- #pragma segment Main
- void DoIdleTasks(EventRecord *event)
- {
- #ifndef __MWERKS__
- #pragma unused (event)
- #endif
-
- WindowPtr ww;
- FileRecHndl ff;
- ControlHandle ctl;
- EventRecord evt;
- TEHandle te;
- Rect rr;
- KeyMap kk;
- short mm;
-
- static long waitSome;
-
- if (gStartingUp) {
- if (FrontWindow()) {
- gStartingUp = false;
- waitSome = 0;
- IsCtlEvent(nil, event, nil, nil);
- return;
- }
- if (!waitSome) waitSome = TickCount() + 30;
- else {
- if (waitSome < TickCount()) {
- gStartingUp = false;
- waitSome = 0;
- gDialogErr = NewDocumentWindow(nil, gAppWindowType, true);
- if (gDialogErr)
- NewDocumentWindow(nil, 'ERR#', false);
- }
- }
- IsCtlEvent(nil, event, nil, nil);
- return;
- }
-
- for (ww = nil; (ww = GetNextWindow(ww, gAppWindowType)) != nil;) {
- ff = (FileRecHndl)GetWRefCon(ww);
- if ((*ff)->connect.connected == 1) {
- CNum2Ctl(ww, 1010, &ctl);
- (*ctl)->contrlVis = false;
- BeginFrame(ww);
- CNum2Ctl(ww, 1020, &ctl);
- ShowStyledControl(ctl);
- CNum2Ctl(ww, 1000, &ctl);
- ShowStyledControl(ctl);
- EndFrame(ww);
- (*ff)->connect.connected++;
- BeginContent(ww);
- SendMessage(ff, kStylMssg);
- SendMessage(ff, kTextMssg);
- EndContent(ww);
- }
- }
-
- if (TSMTEAvailable()) TSMEvent(event);
-
- GetKeys(kk);
- mm = (kk[1] & 0x8000) ? (cmdKey ) : 0;
- mm |= (kk[1] & 0x0004) ? (optionKey ) : 0;
- mm |= (kk[1] & 0x0008) ? (controlKey) : 0;
- mm |= (kk[1] & 0x0001) ? (shiftKey ) : 0;
- evt.what = nullEvent; /* Make valid null event, with modifiers. */
- evt.modifiers = mm;
- IsCtlEvent(nil, &evt, nil, nil);
-
- ww = CTETargetInfo(&te, &rr);
- if (ww) {
- if (rr.left < -8192) /* If TextEdit control is in the frame... */
- BeginFrame(ww); /* Set clipping to the frame area. */
- else
- BeginContent(ww); /* Else set clipping to the document area. */
- CTEIdle();
- EndContent(ww); /* EndContent can be used to close a BeginFrame. */
- }
- }
-
-
-
-